//
//  FSCSViewController.m
//  WZSOA
//
//  Created by 刘沿 on 16/6/7.
//  Copyright © 2016年 刘沿. All rights reserved.
//

#import "FSCSViewController.h"
//#import "FSCSCell.h"
#import "SDLeftTableViewController.h"
#import "FSHomeUpDoingController.h"
#import "FSNewReceiveController.h"
#import "FSHomeViewController.h"
#import "FSUpDoingReceiveController.h"
#import "FSXXXXXXViewController.h"

@interface FSCSViewController ()

@property (nonatomic,strong) NSMutableArray *contentArray;

@property (nonatomic,strong) UINavigationController *nav;

@property (nonatomic,strong) FSHomeViewController *home;

@property (nonatomic,strong) FSNewReceiveController *rec;

@property (nonatomic,strong) FSNewSendController *send;

@property (nonatomic,strong) FSNewSendController_Second *send_Second;

@property (nonatomic,strong) FSHomeUpDoingController *upDoing;

@property (nonatomic,strong) FSNewReceiveController_Second *rec_Second;

@property (nonatomic,strong) FSToDoingViewController *todoingVC;

//@property (nonatomic,strong) FSNewSendDetailController *newSendDetailVC;

@property (nonatomic,strong) FSHomeEmailViewController *homeMaile;

@property (nonatomic,strong) FSNoticeViewController *noticeVC;

@property (nonatomic,strong) SDLeftTableViewController *left1;
@property (nonatomic,strong) UINavigationController *nav1;

@property (nonatomic,strong) FSPageControlViewController *pageVC;

@property (nonatomic,strong) FSProfileSearchController *profileSer;

@property (nonatomic,strong) FSMessageViewController *messageVC;

@property (nonatomic,strong) FSCellPhoneController *cellPhoneVC;

//二级栏目
@property (nonatomic,strong) FSLeftTabController_Second *leftSec;

@property (nonatomic,strong) FSAlreadyDoViewController *alreadyVc;

@property (nonatomic,strong) FSXXXXXXViewController *xxxx;

@property (nonatomic,strong) FSLeaderPlanViewController *leaderVC;

@end

@implementation FSCSViewController

static NSString * const reuseIdentifier = @"CSCell";

- (void)viewDidLoad {
    [super viewDidLoad];

    self.maximumPrimaryColumnWidth = 200;
    
    UINavigationController  *nav1 =  self.childViewControllers[0];
    SDLeftTableViewController *master = nav1.childViewControllers[0];
    self.nav1 = nav1;
    
    UINavigationController  *nav =  self.childViewControllers[1];
    self.nav = nav;

    FSHomeViewController *home = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewVC"];
    
    FSNewReceiveController *rece = [self.storyboard instantiateViewControllerWithIdentifier:@"NewReceiveVC"];
    
    
    FSNewSendController *send = [self.storyboard instantiateViewControllerWithIdentifier:@"NewSendVC"];
    
    FSNewSendController_Second *send_Second = [self.storyboard instantiateViewControllerWithIdentifier:@"NewSend_SecondVC"];//[[FSNewSendController_Second alloc] init];//[self.storyboard instantiateViewControllerWithIdentifier:@"NewSend_SecondVC"];
    
    FSHomeUpDoingController *upDoing = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeUpDoingVC"];//[[FSHomeUpDoingController alloc] init];
//
    FSNewReceiveController_Second *receive_Second = [self.storyboard instantiateViewControllerWithIdentifier:@"NewReceive_SecondVC"];
    
    FSToDoingViewController *todoingVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ToDoingViewVC"];//[[FSToDoingViewController alloc] init];
    
    FSHomeEmailViewController *homeEmail = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeEmailVC"];
    
    FSNoticeViewController *notice = [[FSNoticeViewController alloc] init];
    
    FSLeftTabController_Second *leftSe = [[FSLeftTabController_Second alloc] init];
    
    FSAlreadyDoViewController *alVC = [[FSAlreadyDoViewController alloc] init];
    
    FSLeaderPlanViewController *lead = [[FSLeaderPlanViewController alloc] init];
    
    FSPageControlViewController *pageVC = [[FSPageControlViewController alloc] init];
    
    FSProfileSearchController *pofileVC = [[FSProfileSearchController alloc] init];
    
    
    FSMessageViewController *messageVC = [[FSMessageViewController alloc] init];
    
    FSCellPhoneController *cellVC = [[FSCellPhoneController alloc] init];
    
    
//    SDLeftTableViewController *left1 = nav1.childViewControllers[0];
    
//二级栏目

//跳转时让cell背景色恢复默认
    [leftSe setColorBlock:^(UITableViewCell *cell) {
        
        NSIndexPath *indexPath = [master.tableView indexPathForSelectedRow];
        
        UITableViewCell *cell2 = [master.tableView cellForRowAtIndexPath: indexPath];

       cell2.backgroundColor = [UIColor colorWithRed:0/255.0 green:94/255.0 blue:219 /255.0 alpha:1];
        
        
        cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:94/255.0 blue:219 /255.0 alpha:1];
        
    }];
    
    self.alreadyVc = alVC;
    self.leftSec = leftSe;
    self.left1 = master;
    self.rec_Second = receive_Second;
    self.home = home;
    self.rec = rece;
    self.send = send;
    self.send_Second = send_Second;
    self.upDoing = upDoing;
    self.todoingVC = todoingVC;
    self.homeMaile = homeEmail;
    self.noticeVC = notice;
    self.leaderVC = lead;
    self.pageVC = pageVC;
    self.profileSer = pofileVC;
    self.messageVC = messageVC;
    self.cellPhoneVC = cellVC;

    [master setMyBlock:^(NSInteger index) {
        
        switch (index) {
            case 0:
                [self loadDifferentController:0];
                break;
            case 1:
                [self loadDifferentController:1];
                break;
            case 2:
                [self loadDifferentController:2];
                break;
            case 3:
                [self loadDifferentController:3];
                break;
            case 4:
                [self loadDifferentController:4];
                break;
            case 5:
                [self loadDifferentController:5];
                break;
            case 6:
                [self loadDifferentController:6];
                break;
            case 7:
                [self loadDifferentController:7];
                break;
            case 8:
                [self loadDifferentController:8];
                break;
            case 9:
                [self loadDifferentController:9];
                break;
            case 10:
                [self loadDifferentController:10];
                break;
            case 11:
                [self loadDifferentController:11];
                break;
            case 12:
                [self loadDifferentController:12];
                break;
            default:

                break;
        }
        
    }];

}

-(void)loadDifferentController:(NSInteger)index{
    
    if (index == 0) {
        self.nav.viewControllers = @[self.home];
        
    }else if(index == 1){
    
        //self.nav.viewControllers = @[self.rec];

        self.nav.viewControllers = @[self.upDoing];
    
    }else if(index == 2){
    
        self.nav.viewControllers = @[self.todoingVC];

    }else if(index == 3){
    
        self.nav.viewControllers = @[self.send_Second];
  
    }else if(index == 4){
        
        self.nav.viewControllers = @[self.rec_Second];
        
    }else if(index == 5){
        self.maximumPrimaryColumnWidth = 250;

//政务公告  二级栏目
        UINavigationController *nav2 = self.childViewControllers[0];
        
        nav2.viewControllers = @[self.leftSec];
        
//点进二级栏目  显示的页面
        self.nav.viewControllers = @[self.alreadyVc];
        
        self.leftSec = nav2.viewControllers[0];
        
        __weak typeof (self) weakSelf = self;
        
        [self.leftSec setRecentBlock:^(NSUInteger index) {
            
            if (index == 1) {
//  已办发文流转
                weakSelf.alreadyVc.type = alreadySend;
                
                weakSelf.nav.viewControllers = @[weakSelf.alreadyVc];
                
            }else if(index == 0){
//  首页
        weakSelf.maximumPrimaryColumnWidth = 200;

        weakSelf.nav.viewControllers = @[weakSelf.home];
                
        nav2.viewControllers = @[weakSelf.left1];
                
            }else if (index == 2){
//  已办收文流转
                FSAlreadyDoViewController *alVC1 = [[FSAlreadyDoViewController alloc] init];

                alVC1.type = alreadyReceive;
                
                weakSelf.nav.viewControllers = @[alVC1];
            
            }else if(index == 3){
//  已办收文已归档
                FSAlreadyDoViewController *alVC2 = [[FSAlreadyDoViewController alloc] init];
                
                alVC2.type = alreadyReceiveArchive;
                
                weakSelf.nav.viewControllers = @[alVC2];
            
            }else {
//   已办发文已归档
                
                FSAlreadyDoViewController *alVC = [[FSAlreadyDoViewController alloc] init];
                
                alVC.type = alreadySendArchive;
                
                weakSelf.nav.viewControllers = @[alVC];
            
            }
            
        }];
        
        
    }else if(index == 6){
        
        self.nav.viewControllers = @[self.profileSer];
        
    }else if(index == 7){
        
        self.nav.viewControllers = @[self.noticeVC];
        
    }else if(index == 8){
        
        self.nav.viewControllers = @[self.leaderVC];
        
    }else if(index == 9){
        
        self.nav.viewControllers = @[self.cellPhoneVC];
        
    }else if(index == 10){
    
        self.nav.viewControllers = @[self.homeMaile];
    
    }else if(index == 11){
        
        self.nav.viewControllers = @[self.messageVC];
        
    }else if(index == 12){
        
        self.nav.viewControllers = @[self.pageVC];
        
    }
    
}




@end


















